#!/usr/bin/env python
# -*- coding:utf-8 -*-

with open('config','r') as f:
    lines=f.readlines()
print lines
backend_num=lines.index("backend www.oldboy.org\n")
print backend_num


['global\n', '        log 127.0.0.1 local2\n', '        daemon\n', '        maxconn 256\n', '        log 127.0.0.1 local2 info\n', 'defaults\n', '        log global\n', '        mode http\n', '        timeout connect 5000ms\n', '        timeout client 50000ms\n', '        timeout server 50000ms\n', '        option  dontlognull\n', '\n', 'listen stats :8888\n', '        stats enable\n', '        stats uri       /admin\n', '        stats auth      admin:1234\n', '\n', 'frontend oldboy.org\n', '        bind 0.0.0.0:80\n', '        option httplog\n', '        option httpclose\n', '        option  forwardfor\n', '        log global\n', '        acl www hdr_reg(host) -i www.oldboy.org\n', '        use_backend www.oldboy.org if www\n', '\n', 'backend www.oldboy.org\n', '        server 100.1.7.9 100.1.7.9 weight 20 maxconn 3000\n', '\n', 'backend buy.oldboy.org\n', '        server 100.1.7.90 100.1.7.90 weight 20 maxconn 3000\n']